﻿Imports Microsoft.VisualBasic
Imports System.Data

<System.ComponentModel.DataObjectAttribute(True)> _
Public Class BLL_SearchDirtyHeaderControl

    Public Sub New()
        ' 
        ' TODO: 在此加入建構函式的程式碼 
        ' 
    End Sub

    'SELECT 
    <System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.[Select])> _
    Public Function BLL_Select(ByVal showAll As Boolean) As DataTable
        Dim dat As New clsData
        Dim sql As MyStringBuilder

        If showAll = True Then
            sql = New MyStringBuilder
        Else
            sql = New MyVolunterDataFilter
        End If

        sql.AppendFormat("SELECT (C.RegionName+B.RegionName+A.Location) as FullLocation,A.*, A.CreateBy as VolunteerID ")
        sql.AppendFormat("FROM FindDirtyHeader A ")
        sql.AppendFormat("LEFT JOIN Region B on A.VillageId=B.RegionID ")
        sql.AppendFormat("LEFT JOIN Region C on B.Parent=C.RegionID ")
        sql.AppendFormat("LEFT JOIN WorkHeader D on A.WorkHeaderID=D.WorkHeaderID ")
        sql.AppendFormat("WHERE D.WorkHeaderID Is null ")

        Return dat.GetData(sql)

    End Function

End Class
